﻿#region File and License Information
/*
<File>
	<License>
		Copyright © 2009 - 2017, Daniel Vaughan. All rights reserved.
		This file is part of Calcium (http://calciumsdk.net), 
		which is released under the MIT License.
		See file /Documentation/License.txt for details.
	</License>
	<CreationDate>2010-12-27 15:13:08Z</CreationDate>
</File>
*/
#endregion

using System;

namespace Outcoder.InversionOfControl.Containers
{
	/* TODO: [DV] Comment. */
	public class SimpleContainerRegistrar : IDependencyRegistrar
	{
		IContainer Container
		{
			get
			{
				return Dependency.Resolve<IContainer>();
			}
		}

		public bool IsTypeRegistered(Type type)
		{
			return Container.IsRegistered(type);
		}

	    public bool IsTypeRegistered(Type type, string key = null)
	    {
            return key == null ? Container.IsRegistered(type) : Container.IsRegistered(type, key);
	    }

	    public void Register<TFrom, TTo>(bool singleton = false, string key = null) where TTo : TFrom
		{
			Container.Register<TFrom, TTo>(singleton, key);
		}

		public void Register(Type fromType, Type toType, bool singleton = false, string key = null)
		{
			Container.Register(fromType, toType, singleton, key);
		}

		public void Register<TFrom>(TFrom instance, string key = null)
		{
			Container.Register<TFrom>(instance, key);
		}

		public void Register(Type type, object instance, string key = null)
		{
			Container.Register(type, instance, key);
		}

		public void Register<T>(Func<T> getInstanceFunc, bool singleton = false, string key = null)
		{
			Container.Register<T>(getInstanceFunc, singleton, key);
		}

		public void Register(Type type, Func<object> getInstanceFunc, bool singleton = false, string key = null)
		{
			Container.Register(type, getInstanceFunc, singleton, key);
		}
	}
}
